<!--
 * @Description: 全局组件-分页
 * @Author: zyj
 * @Date: 2022-06-07 16:46:59
 * @LastEditors: zyj
 * @LastEditTime: 2022-06-09 13:52:18
-->
<template>
  <div class="pagination">
    <span class="total">共 {{ total }} 条</span>
    <el-pagination
      background
      layout="total, sizes, prev, pager, next, jumper"
      :current-page="pageNum"
      :page-count="pages"
      :page-size="pageSize"
      @current-change="pageChange"
      @size-change="handleSizeChange"
      :page-sizes="[15, 30, 50, 100, 200]"
    >
      <span class="per">每页{{ pageSize }}条</span>
    </el-pagination>
  </div>
</template>
<script>
export default {
  props: {
    pageNum: {
      type: Number,
      default: 1
    },
    pageSize: {
      type: Number,
      default: 10
    },
    total: {
      type: Number,
      default: 1
    }
  },
  computed: {
    pages: function () {
      return Math.ceil(this.total / this.pageSize)
    }
  },
  methods: {
    pageChange(pageNum) {
      this.$emit('goSpecifiedPage', pageNum, 'pageNum')
    },
    handleSizeChange(pageSize) {
      this.$emit('goSpecifiedPage', pageSize, 'pageSize')
    }
  }
}
</script>
<style lang="less" scoped>
.pagination {
  margin: 15px 0;
  text-align: right;
  .el-input__inner {
    text-align: center;
  }
}
.pagination {
  .total {
    display: inline-block;
    font-size: 13px;
    line-height: 32px;
    height: 34px;
    color: #606266;
    margin-right: 5px;
  }
  .el-pagination {
    display: inline-block;
    vertical-align: top;
  }
  .per {
    font-weight: 400;
    color: #606266;
    padding-right: 20px;
  }
}
</style>